import _request from "../../common/_request";
import {Message} from "element-ui";
import _config from "../../common/_config";

let lib_result_multiple = {

    module : 'result.multiple',

    //查询项目列表
    select : function (page, search_where, callback){
        let data = typeof search_where === "function" ? search_where() : {};
        let params = _request._page_params(this.module, 'select', data, page, _config.size);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data.total, response.data.records)
        }, 0);
    },

    //消费详情
    find_info : function (id, stime, etime, callback){
        let data = {};
        data.id = id
        data.stime = stime
        data.etime = etime
        let params = _request._params(this.module, 'find_info', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        }, 0);
    },

    //查询每日明细
    select_date : function (id, stime, etime, callback){
        let data = {};
        data.id = id
        data.stime = stime
        data.etime = etime
        let params = _request._params(this.module, 'select_date', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        }, 0);
    },

    activity_list: function (callback) {
        let params = _request._params(this.module, 'activity_list');
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        }, 0);
    },

    download: function (id, callback) {
        let data = {}
        data.id = id
        let params = _request._params(this.module, 'download', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        }, 0);
    },
}

export default lib_result_multiple
